#include<bits./stdc++.h>
using namespace std;
const int maxn=3000005;
const long long p=998244353;
int n;
char s[maxn];
void work1(){
    int res=0;
    for(int i=1;i<=n;i++){
        if((s[i]=='B')&&(i!=n)) res++;
    }
    res++;
    cout<<res;
}
int f[21][1050000];
long long ans;
int main(){
    freopen("song.in","r",stdin);
    freopen("song.out","w",stdout);
    cin>>(s+1);
    n=strlen(s+1);
    bool flg=1;
    int op=0;
    for(int i=1;i<=n;i++){
        if(s[i]==s[i-1]){
            flg=0;
            break;
        }
        if(s[i]=='B') op=op|(1<<(i-1));
    }
    if(flg){
        work1();
        return 0;
    }
	f[n][op]=1;
	for(int i=n;i>=2;i--){
		for(int j=0;j<(1<<n);j++){
			if(f[i][j]==0) continue;
			for(int w=1;w<n;w++){
				if((j&(1<<(w-1))==0)&&(j&(1<<w)==1)) continue;
				int l=j>>(w+1),r;
				l=l<<(w-1); r=l<<(w+1);
				r=r^j;
				l=l|r;
				f[i-2][j]=1;
			}
		}
	}
	for(int i=n;i>=0;i--){
		for(int j=0;j<(1<<n);j++){
			if(f[i][j]==1) ans++;
		}
	}
	ans=ans%p;
	cout<<ans;
    return 0;
}
